module(..., package.seeall)

import("utils.signalling", "Channel")


function make_channel(name, signals)
    --[[ This function creates a channel, registers the given set of signals, and creates a table 
    of shortcut functions for listening to those signals. ]]
    local channel = Channel(name)
    local bind_shortcuts = {}
    for _, signal_type in pairs(signals) do
        channel:register(signal_type)
        bind_shortcuts["on_" .. signal_type:gsub(" ", "_")] = function(...)
            return channel:listen(signal_type, ...)
        end
    end
    return channel, bind_shortcuts
end
